package com.unicomcz.mobile;

import java.sql.ResultSet;
import java.util.List;

import com.unicomcz.DetailPageAction;

public class MobileOutAction extends DetailPageAction
{
    private String stockNameNew;
    private String stockIdNew;
    private int amount;
    private String modelName;
    private String modelType;
    
    /**
     * @return the stockNameNew
     */
    public String getStockNameNew()
    {
        return stockNameNew;
    }

    /**
     * @param stockNameNew the stockNameNew to set
     */
    public void setStockNameNew(String stockNameNew)
    {
        this.stockNameNew = stockNameNew;
    }

    /**
     * @return the stockIdNew
     */
    public String getStockIdNew()
    {
        return stockIdNew;
    }

    /**
     * @param stockIdNew the stockIdNew to set
     */
    public void setStockIdNew(String stockIdNew)
    {
        this.stockIdNew = stockIdNew;
    }

    /**
     * @return the amount
     */
    public int getAmount()
    {
        return amount;
    }

    /**
     * @param amount the amount to set
     */
    public void setAmount(int amount)
    {
        this.amount = amount;
    }

    /**
     * @return the modelName
     */
    public String getModelName()
    {
        return modelName;
    }

    /**
     * @param modelName the modelName to set
     */
    public void setModelName(String modelName)
    {
        this.modelName = modelName;
    }

    /**
     * @return the modelType
     */
    public String getModelType()
    {
        return modelType;
    }

    /**
     * @param modelType the modelType to set
     */
    public void setModelType(String modelType)
    {
        this.modelType = modelType;
    }

    /* (non-Javadoc)
     * @see com.unicomcz.DetailPageAction#getSqlStr()
     */
    @Override
    public String getSqlStr()
    {
        String sqlStr = "select a.stock_id,b.depart_name,c.terminal_model_code,c.terminal_model_name,sum(a.amount) amount " + 
        		" from dls_terminal_total a,dls_code_dls b,dls_code_terminal c " + 
        		"where a.stock_id=b.depart_id and a.terminal_model_code=c.terminal_model_code " + 
        		"group by a.stock_id,b.depart_name,c.terminal_model_code,c.terminal_model_name";
        return sqlStr;
    }

    /* (non-Javadoc)
     * @see com.unicomcz.ActionBase#getParams()
     */
    @Override
    public Object[] getParams()
    {
        return new Object[]{};
    }

    /* (non-Javadoc)
     * @see com.unicomcz.ActionBase#regQueryParam()
     */
    @Override
    protected void regQueryParam() throws Exception
    {
       
    }

    /* (non-Javadoc)
     * @see com.unicomcz.ActionBase#rs2List(java.sql.ResultSet, java.util.List)
     */
    @Override
    protected void rs2List(ResultSet rs, List out) throws Exception
    {
        StockBean sb = new StockBean();
        sb.setStockId(rs.getString(1));
        sb.setStockName(rs.getString(2));
        sb.setModelType(rs.getString(3));
        sb.setModelName(rs.getString(4));
        sb.setAmount(rs.getString(5));
        out.add(sb);
    }
    
    public String out() {
        boolean dbFlag = setupConn("dls");
        if (!dbFlag) {
            log.debug(userInfo.getUserId()+"登陆系统失败!因为建立数据库连接失败");
            addActionMessage("修改密码失败!因为建立数据库连接失败");
            return INPUT;
        }
        int rtv = execProc("{call mob_out(?,?,?,?,?)}",5);
        if (rtv == 0) {
               addActionMessage("出库成功！");
               amount=0;
        }else if (rtv == -1){
               addActionMessage("出库成功！");
        }
        tearDown();
        return goToPage();
    }
    

}
